﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;

namespace Ooganizer.Resolver
{
    
    [Guid("48882400-2B04-438c-9131-5CA060DCF06A")]
    [InterfaceType(ComInterfaceType.InterfaceIsDual)]
    [ComVisible(true)]
    public interface IFirefoxPluginCallsIntoHere
    {
        /// <summary>
        /// This function is called from the FirefoxPlugin Extension to let us know the selected URLs 
        /// and Titles. We need to store them persistently, so that when we need to resolve when can
        /// access them. (this function will be called into, when certain events happen inside Firefox)
        /// </summary>
        /// <param name="URLs">\n\t seperated list of URLs (first is selected tab URL)</param>
        /// <param name="Titles">\n\t seperated list of Titles (first is selected tab Title)</param>
        void PluginEntersURLsAndTitles(string URLs, string Titles);
    }

    [Guid("A8489FA1-5385-4202-823B-AB232E67D549")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("Ooganizer.FirefoxResolver")]
    [ComVisible(true)]
    public class FoxResolver : IResolver, IResolveable, IFirefoxPluginCallsIntoHere
    {
        public bool CanResolve(string processName)
        {
            // Not fully implemented ... returning false
            return false;
        }

        public ArtifactGroup GetArtifacts(IntPtr hWnd)
        {
            return null;
        }
        
        /// <summary>
        /// We need to store the entered information persistently so that GetArtifact can retrieve it
        /// when it needs it.
        /// </summary>
        /// <param name="URLs">\n\t serperated list of URLs</param>
        /// <param name="Titles">\n\t seperated list of Titles</param>
        public void PluginEntersURLsAndTitles(string URLs, string Titles)
        {
            if (URLs.Length == 0 || Titles.Length == 0)
                return;

            File.WriteAllText(@"C:\doris.txt", (URLs + Titles));            
        }
    }
}
